home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / sun / NET / WWW / AUTH / basic.class (.txt) < prev   
Encoding:
Java Class File  |  1997-04-14  |  2.0 KB  |  171 lines

  1. package sun.net.www.auth;
  2.  
  3. import java.io.FileInputStream;
  4. import java.io.FileOutputStream;
  5. import java.io.IOException;
  6. import java.io.InputStream;
  7. import java.io.OutputStream;
  8.  
  9. public class basic extends Authenticator {
  10.    private static byte[] six2print = new byte[]{65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47};
  11.    private static byte[] print2six = new byte[128];
  12.    static final int ILLEGAL = -1;
  13.  
  14.    public void encrypt(InputStream var1, OutputStream var2) throws IOException {
  15.       int var4 = -1;
  16.       int var5 = 64;
  17.  
  18.       label33:
  19.       while(true) {
  20.          int var6 = 24;
  21.          int var3 = 0;
  22.  
  23.          while(true) {
  24.             var6 -= 8;
  25.             if (var6 < 0) {
  26.                var6 = 24;
  27.  
  28.                while(true) {
  29.                   var6 -= 6;
  30.                   if (var6 < 0) {
  31.                      var5 -= 4;
  32.                      if (var5 == 0) {
  33.                         var2.write(10);
  34.                         var5 = 64;
  35.                      }
  36.                      continue label33;
  37.                   }
  38.  
  39.                   var2.write(six2print[var3 >> var6 & 63]);
  40.                }
  41.             }
  42.  
  43.             switch (var4 = var1.read()) {
  44.                case -1:
  45.                   switch (var6) {
  46.                      case 0:
  47.                         var2.write(six2print[var3 >> 18 & 63]);
  48.                         var2.write(six2print[var3 >> 12 & 63]);
  49.                         var2.write(six2print[var3 >> 6 & 63]);
  50.                         var2.write(61);
  51.                         return;
  52.                      case 8:
  53.                         var2.write(six2print[var3 >> 18 & 63]);
  54.                         var2.write(six2print[var3 >> 12 & 63]);
  55.                         var2.write(61);
  56.                         var2.write(61);
  57.                         return;
  58.                      case 16:
  59.                      default:
  60.                         return;
  61.                   }
  62.                default:
  63.                   var3 |= var4 << var6;
  64.             }
  65.          }
  66.       }
  67.    }
  68.  
  69.    public void decrypt(InputStream var1, OutputStream var2) throws IOException {
  70.       int var6 = 64;
  71.  
  72.       int var4;
  73.       int var5;
  74.       label46:
  75.       while(true) {
  76.          var4 = 24;
  77.          var5 = 0;
  78.  
  79.          while(true) {
  80.             var4 -= 6;
  81.             if (var4 < 0) {
  82.                var4 = 24;
  83.  
  84.                while(true) {
  85.                   var4 -= 8;
  86.                   if (var4 < 0) {
  87.                      var6 -= 4;
  88.                      continue label46;
  89.                   }
  90.  
  91.                   var2.write(var5 >> var4 & 255);
  92.                }
  93.             }
  94.  
  95.             int var3;
  96.             switch (var3 = var1.read()) {
  97.                case -1:
  98.                   if (var4 == 18) {
  99.                      throw new IOException("Invalid encryption");
  100.                   }
  101.                   break label46;
  102.                case 10:
  103.                   if (var6 != 0) {
  104.                      throw new IOException("Invalid encryption");
  105.                   }
  106.  
  107.                   var6 = 64;
  108.                   continue label46;
  109.                case 61:
  110.                   break label46;
  111.                default:
  112.                   byte var7 = print2six[var3];
  113.                   switch (var7) {
  114.                      case -1:
  115.                         throw new IOException("Invalid encryption");
  116.                      default:
  117.                         var5 |= var7 << var4;
  118.                   }
  119.             }
  120.          }
  121.       }
  122.  
  123.       switch (var4) {
  124.          case 0:
  125.             var2.write(var5 >> 16 & 255);
  126.             var2.write(var5 & 255);
  127.             return;
  128.          case 6:
  129.             var2.write(var5 >> 16 & 255);
  130.             return;
  131.          case 12:
  132.             throw new IOException("Invalid encryption");
  133.          case 18:
  134.          default:
  135.       }
  136.    }
  137.  
  138.    public static void main(String[] var0) throws IOException {
  139.       basic var1 = new basic();
  140.       FileOutputStream var2 = new FileOutputStream("/home/jpayne/livejava/test.uu");
  141.       ((Authenticator)var1).encrypt(new FileInputStream("/home/jpayne/livejava/test.ascii"), var2);
  142.       var2.close();
  143.       ((Authenticator)var1).decrypt(new FileInputStream("/home/jpayne/livejava/test.uu"), System.out);
  144.       System.out.flush();
  145.    }
  146.  
  147.    static {
  148.       int var1 = six2print.length;
  149.       int var0 = print2six.length;
  150.  
  151.       while(true) {
  152.          --var0;
  153.          if (var0 < 0) {
  154.             var0 = 0;
  155.  
  156.             while(true) {
  157.                --var1;
  158.                if (var1 < 0) {
  159.                   return;
  160.                }
  161.  
  162.                print2six[six2print[var0]] = (byte)var0;
  163.                ++var0;
  164.             }
  165.          }
  166.  
  167.          print2six[var0] = -1;
  168.       }
  169.    }
  170. }
  171.